#include "stdafx.h"
#include "ckEnumWorkspace.h"
#include "ckWorkspace.h"

namespace ck
{
	namespace data
	{
		EnumWorkspace::EnumWorkspace()
		{
			m_iter = m_workspaces.begin();
		}

		EnumWorkspace::~EnumWorkspace()
		{
			Cleanup();
		}

		void EnumWorkspace::Add(Workspace* pCase)
		{
			if (pCase)
			{
				m_workspaces.push_back(pCase);
			}
		}

		void EnumWorkspace::Cleanup()
		{
			std::vector<Workspace*>::iterator iter;
			for (iter = m_workspaces.begin(); iter != m_workspaces.end(); iter++)
			{
				(*iter)->Release();
			}
			m_workspaces.clear();
		}

		void EnumWorkspace::Reset()
		{
			m_iter = m_workspaces.begin();
		}

		Workspace* EnumWorkspace::Next()
		{
			if (m_iter == m_workspaces.end())
			{
				return NULL;
			}
			return *(m_iter++);
		}
	}
}
